package com.hp.ams.ongoing.netatendimento.infrastructure.factory;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionFactory {

	private static final String driverClassName = "oracle.jdbc.OracleDriver";
	private static String connectionUrl = null;//"jdbc:oracle:thin:@5.16.8.187:1521:db09";
	private static final String dbUser = "H_T0765791";
	private static final String dbPwd = "H_T0765791";

	private static ConnectionFactory connectionFactory = null;

	private ConnectionFactory() {
		try {
			Class.forName(driverClassName);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	public Connection getConnection(String aliasBase) throws SQLException {
		connectionUrl = ConnectionStrategy.getConnectionMap().get(aliasBase);
		Connection conn = null;
		conn = DriverManager.getConnection(connectionUrl, dbUser, dbPwd);
		return conn;
	}

	public static ConnectionFactory getInstance() {
		if (connectionFactory == null) {
			connectionFactory = new ConnectionFactory();
		}
		return connectionFactory;
	}

}
